<%--
  Created by IntelliJ IDEA.
  User: guanz
  Date: 2023/3/3
  Time: 16:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>后台登录</title>
    <meta name="author" content="DeathGhost" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <style>
        body{height:100%;background:#16a085;overflow:hidden;}
        canvas{z-index:-1;position:absolute;}
    </style>
    <script src="js/jquery.js"></script>
    <script src="js/verificationNumbers.js"></script>
    <script src="js/Particleground.js"></script>
    <script>
        $(document).ready(function() {
            //粒子背景特效
            $('body').particleground({
                dotColor: '#5cbdaa',
                lineColor: '#5cbdaa'
            });
            //验证码
            createCode();
            //测试提交，对接程序删除即可
            $(".submit_btn").click(function(){
                location.href="index.html";
            });
        });
    </script>
</head>
<body>
<%--<%Cookie[] arr =  request.getCookies();
String accountname = "";
String accountpwd ="";
    if (arr != null) {
        for (int i = 0; i <arr.length ; i++) {
            if ("accountname".equals(arr[i].getName())){
                accountname = arr[i].getValue();
            }
            if ("accountpwd".equals(arr[i].getName())){
                accountpwd = arr[i].getValue();
            }
        }
    }
    request.getRequestDispatcher("AccountServlet?flag=login&accountName="+accountname
    +"&accountPwd="+accountpwd).forward(request,response);
%>--%>
<dl class="admin_login">
    <dt>
        <strong>站点后台管理系统</strong>
        <em>Management System</em>
    </dt>
    <div style="color: red">${requestScope.msg}</div>
   <form action="AccountServlet?flag=login" method="post">
       <dd class="user_icon">
           <input type="text" id="nid" placeholder="账号" class="login_txtbx" name="accountName"/>
       </dd>
       <dd class="pwd_icon">
           <input type="password" id="pid" placeholder="密码" class="login_txtbx" name="accountPwd"/>
       </dd>
       <dd class="val_icon">
           <div class="checkcode">
               <input type="text" id="J_codetext" placeholder="验证码" maxlength="4" class="login_txtbx">
               <canvas class="J_codeimg" id="myCanvas" onclick="createCode()">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
           </div>
           <input type="button" value="验证码核验" class="ver_btn" onClick="validate();">
       </dd>
       <dd >
           <div class="pwd_icon">
                <input type="checkbox" name="" id=""  onclick="savePwd()" >记住密码
           </div>
       </dd>
       <dd>
           <input type="submit" value="立即登录" class="submit_btn"/>
       </dd>
   </form>
    <dd>
        <p>© 2023-2023 QIANFENG 版权所有</p>
        <p>辽宁大连</p>
    </dd>
</dl>
</body>
<script>
    function savePwd(){
        // accountname=admin; accountpwd=123456
       //  console.log(document.cookie);
       // console.log( getCookie("accountname"));
        var accountname = getCookie("accountname");
        var accountpwd = getCookie("accountpwd");
        setCookie("accountname",accountname,3);
        setCookie("accountpwd",accountpwd,2);
        document.getElementById("nid").value=accountname;
        document.getElementById("pid").value=accountpwd;
    }
    function getCookie(cookname){
        var arr = document.cookie.split(";");
        for(var i=0;i<arr.length;i++){
            var n = arr[i].trim();
            var cname = cookname+"=";
            if(n.indexOf(cname)==0){
                return n.substring(cname.length);
            }
        }
    }
    function setCookie(cname,cvalue,exdays){
        var d = new Date();
        d.setTime(d.getTime()+(exdays*24*60*60*1000));
        var expires = "expires="+d.toGMTString();
        document.cookie = cname + "=" + cvalue + "; " + expires;
    }
</script>
</html>

